package com.fit.pages;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.fit.interfaces.CarI;
import com.fit.interfaces.User;
import com.fit.service.CarsI;

public class DisplayCar {

	@SessionState
	private User user;
	
	private boolean userExists;

	public User getUser() {
		return user;
	}

	Object onActivate(){
		if(!userExists) return Login.class;
		if(car == null) return Index.class;
		return null;
	}
	
	
	private CarI car;
	
	@Inject
	@Property
	private CarsI cars;
	
	public void onActivate(long car_id) {		    
	 		  car = cars.retriveSingleCar(car_id);
	 }
	long onPassivate() {
		return car.getId();
	}
	
	public CarI getCar() {
		return car;
	}
	public void setCar(CarI car) {
		this.car = car;
	}
	 
	 
}
